package com.xbjtech.adapter;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import com.alibaba.fastjson.serializer.ValueFilter;

public class BigDecimalJSONSerializer implements ValueFilter {
	
	private String pattern = "#,###.00";

	@Override
	public Object process(Object object, String name, Object value) {
		if (null != value && value instanceof BigDecimal) {
			DecimalFormat decimalFormat = new DecimalFormat(this.pattern);
			String formatvalue = decimalFormat.format(value);
			return formatvalue;
		}
		return value;
	}
	
	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

}
